package com.weblog.search.controller;

import entity.Result;
import entity.StatusCode;
import enums.ExceptionEnum;
import exception.MyException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 统一异常处理类
 */
@ControllerAdvice
public class CommonExceptionHandler {
    @ExceptionHandler(value = MyException.class)
    @ResponseBody
    public Result handleException(MyException e){
        ExceptionEnum em = e.getExceptionEnum();
        return new Result(false, StatusCode.ERROR,"执行出错");
    }
}
